package controllers

import (
	beego "github.com/beego/beego/v2/server/web"
	"ocane/models"
	"time"
)

type UserRegisterController struct {
	beego.Controller
}

func (this *UserRegisterController) Post(){
		phone := this.GetString("phone")
		companyNAme := this.GetString("companyName")
		industryType := this.GetString("industryType")
		technologyStack := this.GetString("technologyStack")
		openId := this.GetString("openId")
		//user := models.GoUser{Phone: phone, CompanyName: companyNAme, IndustryType: industryType, TechnologyStack: technologyStack, OpenId: openId, CreateDate: time.Now()}
		user := models.GoUser{}
		user.Phone = phone
		user.CompanyName = companyNAme
		user.IndustryType = industryType
		user.TechnologyStack = technologyStack
		user.OpenId = openId
		user.City = ""
		user.Province = ""
		user.Name = "testUser_" + openId
		user.UpdateDate = time.Now()
		user.Account = "test_" + openId
		user.HeadImageUrl = "https://test.png"
		user.AccountIsOk = 1
		user.Region = ""
		user.Sex = 1
		user.Age = 12
		result := models.AddUser(user)

		code := 200
		if !result {
			code = 500
		}
		this.Data["json"] = models.Result{
			Code: code,
			Data: user,
		}
		this.ServeJSON()
}
